package com.example.common.config;

public class AppConfig {

    // 默认环境
    private EnvEnum mEnv = EnvEnum.DEV;

    private static volatile AppConfig mInstance = null;

    /**
     * 获取单例
     *
     * @return
     */
    public static AppConfig getInstance() {
        if (mInstance == null) {
            synchronized (AppConfig.class) {
                if (mInstance == null) {
                    mInstance = new AppConfig();
                }
            }
        }
        return mInstance;
    }


    public EnvEnum getEnv(){
        return mEnv;
    }

    public IConfig getConfig(){
        if (mEnv == EnvEnum.DEV) {
            return new DevConfig();
        } else if (mEnv == EnvEnum.STAGE){
            return new StageConfig();
        } else {
            return new ProdConfig();
        }
    }

    public enum EnvEnum {
        DEV,
        STAGE,
        PROD
    }
}
